
<template>
    <view class="content">
		<view>
			<liu-rotating-menu :btnObj="btnObj" @click="click"></liu-rotating-menu>
		</view>
        <div class="mui-content-padded">

            <!-- 列表组件 -->
            <cc-listView :productList="projectList" ></cc-listView>

        </div>
    </view>
</template>

<script>
	import Vue from 'vue'
	import Router from '@/router'
    export default {
        data() {
            return {
                // 列表数组
                projectList: [],
				btnObj: {
				    id: '1',
				    name: '菜单',
				    childs: [{
				        id: '1',
				        name: '主页'
				    }, {
				        id: '2',
				        name: '用户'
				    }, {
				        id: '3',
				        name: '识别'
				    }]
				},
            }
        },
         created() {
            this.requestData();
        },
        methods: {
           
            requestData() {
				this.$axios.get('users') 
				.then(response=>{
                    let users =response.data;
					this.projectList = [];
					console.log(users)
					for (let user of users) {
					    this.projectList.push({
					        'proName': "用户名:"+user.username,
					        'proUnit': "邮箱:"+user.email,
					        'area': "用户id:"+user.id,
					        'stage': "电话:"+user.telephone,
					        'id': user.id
					    });
					}
                })
                .catch(err=>{
                    console.log(err)
                })   
            },
			//点击菜单
			click(e) {
				if(e.id=="1"){
					uni.showToast({
									title: "进入主页面",
									icon: 'success',    
									duration: 2000    //持续时间为 2秒
								})
					uni.redirectTo({url:'/pages/index/main'})//关闭本页面然后路由跳转
					// Router.push({ name:'main'}); 	 			
					console.log('所点击菜单信息：', e)
				}else if(e.id=="2"){
					uni.showToast({
									title: "您已经在用户页",
									icon: 'success',    
									duration: 2000    //持续时间为 2秒
								})
					console.log('所点击菜单信息：', e)
				}else{
					uni.showToast({
									title: "到达功能页面",
									icon: 'success',    
									duration: 2000    //持续时间为 2秒
								})
					console.log('所点击菜单信息：', e)
					uni.redirectTo({url:'/pages/index/passport'})//关闭本页面然后路由跳转
				}
							
			},

        }
    }
</script>

<style>
    page {

        background-color: #f7f7f7;
    }

    .content {
        display: flex;
        flex-direction: column;

    }

    .mui-content-padded {
        margin: 0px 14px;
        /* background-color: #ffffff; */
    }
</style>